import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/Layout/Layout'
import Laynav from '@/Layout/Laynav'

// 角色类型
const roles = {
  'r1': 'superadmin', // 超级管理员
  'r2': 'admin',      // 管理员
  'r3': 'listener',   // 普通用户
}

const addRoles = (...opt) => {
  const result = []
  opt.forEach(i => {  
    result.push(roles[i])
  })
  return result
}

//hidden 隐藏
// menu: 菜单功能
export const geneRouters = [
  {
    path: '/',
    component: Layout,
    children: [
      { 
        path: 'gathers',
        name: 'gathers',
        component: () => import('@/pages/gathers/index'),
        meta: { auth: false },
      },
      { 
        path: 'feedback',
        name: 'feedback',
        component: () => import('@/pages/feedback/index'),
        meta: { auth: false },
      },
      { 
        path: 'search',
        name: 'search',
        component: () => import('@/pages/search/index'),
        meta: { auth: false },
      },
      { 
        path: 'itemhot',
        name: 'itemhot',
        component: () => import('@/pages/itemhot/index'),
        meta: { auth: false },
      },
      {
        path: 'share',
        name: 'share',
        component: () => import('@/pages/share/index'),
        meta: { auth: false },
      },
      { 
        path: 'config',
        // component: () => import('@/pages/config/index'),
        component: Laynav,
        meta: { auth: false },
        redirect:'/',
        children: [
          { 
            path: '',
            name: 'config',
            component: () => import('@/pages/config/index'),
            meta: { auth: false },
          },
          { 
            path: 'g_create',
            name: 'g_create',
            component: () => import('@/pages/gathers/create/cindex'),
            meta: { auth: false },
          },
        ]
      },
      {
        path: '',
        name: 'home',
        component: () => import('@/pages/home/index'),
        meta: { auth: false }  
      },
    ],
  },
  {
    path: '*',
    component: () => import('@/pages/pageError/index'),
    // redirect: '/',
    // hidden: true 
  },
]

Vue.use(Router)

export default new Router({
  mode: 'hash',
  // mode:'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: geneRouters
})